package com.daigou.dto;

import java.io.Serializable;

import com.daigou.model.User;
import com.daigou.tools.AuthSqlBuilder;

public class Query implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int pageIndex = 1; //当前显示页
	
	private int pageSize = 20; //默认显示的记录数
	
	private Long shopId;
	
	private Long creatorId;
	
	private String searchKey;
	
	private String authSql;
	
	private User user;
	/**
	 * 分页和权限
	 * @param tableAlias
	 */
	public void buildPage(String tableAlias){
		//设置分页
		this.setPageIndex((this.getPageIndex()-1)*this.getPageSize());
		//设置权限0,超级管理员,1，店铺管理员，2，业务经理，3，业务员
		StringBuilder authSql = AuthSqlBuilder.buildAuthSql(this.getUser(), tableAlias);
		this.setAuthSql(authSql.toString());
	}
	/**
	 * 只有分页
	 */
	public void buildPage(){
		//设置分页
		this.setPageIndex((this.getPageIndex()-1)*this.getPageSize());
	}
	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public Long getShopId() {
		return shopId;
	}

	public void setShopId(Long shopId) {
		this.shopId = shopId;
	}

	public Long getCreatorId() {
		return creatorId;
	}

	public void setCreatorId(Long creatorId) {
		this.creatorId = creatorId;
	}

	public String getSearchKey() {
		return searchKey;
	}

	public void setSearchKey(String searchKey) {
		this.searchKey = searchKey;
	}

	public String getAuthSql() {
		return authSql;
	}

	public void setAuthSql(String authSql) {
		this.authSql = authSql;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
